<?php
class AdminModel extends Orm_Base{
	public $table = 'admin';
	public $field = array(
		'id' => array('type' => "int(11) unsigned", 'comment' => 'id'),
		'w_id' => array('type' => "int(11) unsigned", 'comment' => '关联员工ID'),
		'name' => array('type' => "varchar(50)", 'comment' => ''),
		'passwd' => array('type' => "varchar(32)", 'comment' => ''),
		'private_key' => array('type' => "varchar(5)", 'comment' => ''),
		'role' => array('type' => "tinyint(1)", 'comment' => ''),
        'department' => array('type' => "varchar(20)",'comment' => '管理部门'),
		'created' => array('type' => "int(11)", 'comment' => ''),
		'updated' => array('type' => "int(11)", 'comment' => ''),
		'status' => array('type' => "tinyint(4)", 'comment' => ''),
		'is_delete' => array('type' => "tinyint(1)", 'comment' => ''),
        'user' => array('type' => "varchar(50)",'comment' => ''),
	);
	public $pk = 'id';
    //创建TOKEN
    public function creattoken($sw_id){
        $tTime = time();
        $tEndtime = ($tTime+86400*7);
        
        $tToken = md5(md5($sw_id) . $tTime . 'lylpyp');
        $tMO = new SupportworkertokenModel;
        $tData = array(
            'created' => $tTime,
            'token' => $tToken,
            'sw_id' => $sw_id,
            'endtime' => $tEndtime,
        );
        $tMO->insert($tData);
        return array('token' => $tToken,'sw_id' => $sw_id);
    }

    public $tAuth = array(
    );
}
